<?php class Model_User_Login {
	public static function login($values){
		// get default adapter
		$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
		$authAdapter->setTableName('users')
					->setIdentityColumn('login')
					->setCredentialColumn('pswd');
         $authAdapter->setIdentity($values['login'])
         			 ->setCredential(Model_User_User::hash($values['pswd']));
		$auth = Zend_Auth::getInstance();
		$result = $auth->authenticate($authAdapter);
        if($result->isValid()){
        	$storage = new Zend_Auth_Storage_Session();
            $storage->write($authAdapter->getResultRowObject());
            return true;
         }else{
         	return false;
         }        
    }    
    public static function logOut(){
    	 Zend_Auth::getInstance()->clearIdentity();
    }    
}